package ods

import java.util.Properties

import org.apache.flink.api.common.serialization.SimpleStringSchema
import org.apache.flink.streaming.connectors.kafka.FlinkKafkaConsumer

/**
 * @author: yehw
 * @date: 2021/3/10 下午10:09
 * @description: 获取kafka资源
 */
class SourceKafka {

  def getKafkaSource(topic:String):FlinkKafkaConsumer[String]={
    val properties = new Properties()
    properties.setProperty("bootstrap.servers","linux123:9092")
    properties.setProperty("group.id","consumer-group")
    properties.setProperty("key.deserializer","org.apache.kafka.common.serialization.StringDeserializer")
    properties.setProperty("value.deserializer","org.apache.kafka.common.serialization.StringDeserializer")
    properties.setProperty("auto.offset.reset","latest")
    new FlinkKafkaConsumer[String](topic, new SimpleStringSchema(),properties);
  }

}
